linux_note

Debug grub and linux source code with GDB

Knowledge of assembly, shell, C are needed

work space

[email protected]:jindian/linux_startup.git

Both GRUB2 and linux source code included in above repository, file create_grub2_boot_disk_img.sh is used to create bootable disk image.

guide of debug with gdb

About how to compile grub2 and linux source code, create bootable disk image etc, read the instructions in README of linux_startup repository

debug GRUB2

  1. start qemu simulator: qemu-system-i386 -s -S disk.img disk.img is created with shell script create_grub2_boot_disk_img.sh
  2. in directory grub-2.00/grub-core, start gdb: gdb -x gdb_grub gdb_grub is a gdb source file, in which we define useful routines used in gdb and configure command executed after gdb startup
  3. set break point, for example at the entry of master boot record: break *0x7c00
  4. press 'c' to continue
  5. ...

debug linux

  1. the first step is same with debug GRUB2
  2. in directory linux start gdb: gdb -x gdb_linux
  3. in gdb_linux the first break point at start_kernel already set, set other break points as you want
  4. press 'c' to continue
  5. ...

Links

results matching ""

    No results matching ""